package com.ys.service.sys;

import java.util.List;

import org.springframework.context.ApplicationContext;
import org.springframework.ui.Model;

import com.bo.dto.NameValueSelectDto;
import com.ys.entity.base.BaseEntity;
import com.ys.vo.LayuiTableVoJA;
import com.ys.vo.R;

import lombok.AllArgsConstructor;
import lombok.Data;

public interface CommonApiService<E extends BaseEntity<E>> {

	LayuiTableVoJA searchLay(E entity);

    R deleteFalse(ApplicationContext ac, String className, Long id) throws Exception;

    R deleteTrue(ApplicationContext ac, String className, Long id);

    String toAdd(Model model, E entity);
    String toEdit(Model model, E entity, Long id);
	@Data
	@AllArgsConstructor
	public class ToFormDto{
		private Long id; // 主键ID
		private List<RowDto> rows;
		private String pathCommit;

		@Data
		@AllArgsConstructor
		public static class RowDto {
			private List<FormDto> formArr;
			
			@Data
			@AllArgsConstructor
			public static class FormDto {
				private String code; // 字段编码
				private String name; // 字段名称
				private Integer type; // 字段类型，见ENUM
				private String value; // 字段值
				private List<NameValueSelectDto> optionArr;
			}
		}
	}
}
